package cn.ikun.dhj.lianxi1;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class AppCore {
    public static void main(String[] args)throws Exception {
        // TODO
        // 1. 通过反射得到 CustomerService 类的实例 c
        // 2. 调用实例 c 的 say 方法并正确看到结果

        Class<?> aClass = Class.forName("cn.ikun.dhj.lianxi1.CustomerService");
        Class<?> bClass = Class.forName("cn.ikun.dhj.lianxi1.UserService");
        Object o = aClass.newInstance();
        Object c = bClass.newInstance();
        Field service = aClass.getDeclaredField("service");
        service.setAccessible(true);
        service.set(o,c);
        Method say = aClass.getMethod("say");
        say.invoke(o);


    }
}

